﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ATM
{
    public class InsertEnvelopState : ATMState
    {
        public ATM atm;

        public InsertEnvelopState(ATM atm)
        {
            this.atm = atm;
        }

        public void pressPowerButton()
        {
            return;
        }

        public void pressTakeCashButton()
        {
            return;
        }

        public void pressInsertEnvelopButton()
        {
            this.atm.depositSlot.Text = "[-------]";
            this.atm.insertEnvelopButton.Enabled = false;
            this.atm.enterButton.Enabled = true;
            this.atm.screen.Text = "已成功放入信封，请输入存款金额:";
            return;
        }

        public void pressEnterButton()
        {
            if (this.atm.keypadScreen.Text == "")
            {
                System.Windows.Forms.MessageBox.Show("请输入数字后按Enter键确认!");
                return;
            }

            this.atm.commandString = this.atm.keypadScreen.Text;
            this.atm.commandNumber = Convert.ToInt32(this.atm.commandString);
            this.atm.keypadScreen.Text = "";

            this.atm.deposit.account = this.atm.currentAccountID;
            this.atm.deposit.depositAmount = this.atm.commandNumber;

            this.atm.deposit.depositMoney(this.atm.belongTo,this.atm.bankDatabase);

            this.atm.receipt.receiptDetails = "账号："+this.atm.deposit.account+"\r\n";
            this.atm.receipt.receiptDetails += "交易类型: 存款\r\n";
            this.atm.receipt.receiptDetails += "存款金额：" + this.atm.deposit.depositAmount+"\r\n";
            this.atm.receipt.receiptDetails += "存款手续费：" + this.atm.deposit.commission + "\r\n";
            this.atm.receipt.receiptDetails += "账户余额：" + this.atm.bankDatabase.balanceInquiry(this.atm.deposit.account);
            this.atm.log.addLog(this.atm.receipt.receiptDetails);
            this.atm.depositSlot.Text = "[=======]";

            this.atm.setState(this.atm.depositState);
            this.atm.screen.Text = "存款成功!";
            this.atm.screen.Text += "\r\n\r\n";
            this.atm.screen.Text += "请选择下一步操作:\r\n";
            this.atm.screen.Text += "1、继续业务\r\n";
            this.atm.screen.Text += "2、打印凭条";

            return;
        }
    }
}
